// 新增配置
import request from "@/utils/request";
import defaultSettings from "@/settings";

export const apiUrlConfig = {
  queryUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryFlowIns`,
  exportUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryFlowIns`,
  delUrl: ``,
}

export const apiMissionDetailsUrlConfig = {
  queryUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryNodeInsByFlowInsid`,
  exportUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryNodeInsByFlowInsid`,
  delUrl: ``,
}

export const apiSplitDetailsUrlConfig = {
  queryUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryNodeSplitByNid`,
  exportUrl: `${defaultSettings.ctx.batchApp}/s/taskMsg/queryNodeSplitByNid`,
  delUrl: ``,
}
/**
 * 取消任务
 {"flowCode":"","requestNo":""}
 * @param data
 * @returns {AxiosPromise}
 */
export function cancel(flowInstanceId) {
  return request({
    url: `${defaultSettings.ctx.batchApp}/s/taskMsg/cancel`,
    method: 'post',
    data: {
      flowInstanceId: flowInstanceId,
    }
  })
}

/**
 * 流程重跑
 * @param flowCode
 * @param requestNo
 * @returns {AxiosPromise}
 */
export function flowReRun(flowCode,requestId) {
  return request({
    url: `${defaultSettings.ctx.batchApp}/s/taskMsg/flowRetry`,
    method: 'post',
    data: {
      flowCode: flowCode,
      requestId: requestId,
    }
  })
}

/**
 * 节点重跑
 * @param flowCode
 * @param nodeCode
 * @param requestNo
 * @returns {AxiosPromise}
 */
export function nodeReRun(flowInstanceId,nodeInstanceId) {
  return request({
    url: `${defaultSettings.ctx.batchApp}/s/taskMsg/nodeRetry`,
    method: 'post',
    data: {
      flowInstanceId: flowInstanceId,
      nodeInstanceId: nodeInstanceId,
    }
  })
}

/**
 * 续跑任务
 * @param flowCode
 * @param requestNo
 * @returns {AxiosPromise}
 */
export function nodeContinueRun(flowInstanceId,nodeInstanceId) {
  return request({
    url: `${defaultSettings.ctx.batchApp}/s/taskMsg/nodeRenew`,
    method: 'post',
    data: {
      flowInstanceId: flowInstanceId,
      nodeInstanceId: nodeInstanceId,
    }
  })
}
